/**
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 2010 Bull S.A.S.
 * Contact: jonas-team@ow2.org
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 *
 * --------------------------------------------------------------------------
 * $Id: DefaultUriAnalyzerTestCase.java 204 2010-08-26 15:55:05Z guillaume.sauthier $
 * --------------------------------------------------------------------------
 */


package org.osami.gateway.display.internal.uri.internal;

import java.util.Map;

import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

/**
 * A {@code DefaultUriAnalyzerTestCase} is ...
 *
 * @author Guillaume Sauthier
 */
public class DefaultUriAnalyzerTestCase {

    private DefaultUriAnalyzer analyzer;

    @Test
    public void testUniqueTemplate() throws Exception {
        analyzer = new DefaultUriAnalyzer("/test/{id}");
        Map<String, String> result = analyzer.analyze("/test/012345");
        Assert.assertEquals(result.get("id"), "012345");
    }

    @Test
    public void testMultipleTemplates() throws Exception {
        analyzer = new DefaultUriAnalyzer("/test/{id}/{type}");
        Map<String, String> result = analyzer.analyze("/test/012345/abcdef");
        Assert.assertEquals(result.get("id"), "012345");
        Assert.assertEquals(result.get("type"), "abcdef");
    }

    @Test
    public void testOnlyTemplate() throws Exception {
        analyzer = new DefaultUriAnalyzer("{try}");
        Map<String, String> result = analyzer.analyze("something");
        Assert.assertEquals(result.get("try"), "something");
    }
}
